<!-- 订单物流发货 -->
<style>
	.delivery-box{padding:20px;/*border-bottom:1px solid #e6e6e6;*/}
	.layui-table-body{overflow:unset;}
	.delivery-content{padding: 7px 0!important;}
	.layui-table-view{border-top:1px solid #eee;border-bottom:1px solid #eee;}
	.order-delivery .layui-table{/*margin-bottom: 30px;*/}
	.layui-form #order_goods_list thead th, .layui-form #order_goods_list tbody tr{border-bottom: 1px solid #E6E6E6;}
	.layui-form #order_goods_list thead th{background-color: #F5F5F5;line-height: 30px;}
	.layui-text-address {line-height: 25px !important; width: 400px !important;}
	.data-table{display: block; overflow-y: auto; height : 200px}
</style>
<!--发送订单弹出框-->
<script type="text/html" id="order_delivery_html">
<div class="order-delivery">
    <div class="layui-form">

		<input type="hidden" value="{{ d.apply_id }}" name="apply_id"/>

		<div class="layui-form-item">
			<label class="layui-form-label">审核结果：</label>
			<div class="layui-input-block">
				<input type="radio" lay-filter="apply_state" name="apply_state" value="3" title="通过" checked>
				<input type="radio" lay-filter="apply_state" name="apply_state" value="-1" title=拒绝 >
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label"><span class="required">*</span>抽佣比例(%)：</label>
			<div class="layui-input-block">
				<input type="number" name="commission_rate" placeholder="" autocomplete="off" class="layui-input ns-len-mid">
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">商家类型：</label>
			<div class="layui-input-block">
				<input type="radio" name="is_own" lay-filter="is_own" value="0" title="非自营" checked>
				<input type="radio" name="is_own" lay-filter="is_own" value="1" title="自营" >
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">审核信息：</label>
			<div class="layui-input-block">
				<textarea name="apply_message" class="layui-textarea"></textarea>
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label"><span class="required">*</span>商家登录用户名：</label>
			<div class="layui-input-block">
				<input type="text" name="username" placeholder="" autocomplete="off" class="layui-input ns-len-mid">
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label"><span class="required">*</span>商家登录密码：</label>
			<div class="layui-input-block">
				<input type="text" name="password" placeholder="" autocomplete="off" class="layui-input ns-len-mid">
			</div>
		</div>
		
		<div class="ns-form-row">
			<button type="button" class="layui-btn" lay-submit id="button_delivery_order" lay-filter="button_delivery_order" style="display:none;">保存</button>
		</div>


    </div>
</div>
</script>

<script>
    /**
     * 订单发货
     */
	var submitting = false;
    function orderDelivery(apply_id) {

		layui.use(['table', 'form', 'laytpl'], function () {
			var laytpl = layui.laytpl, table = layui.table, form = layui.form;
			form.render();
			//获取模板
			var getTpl = $("#order_delivery_html").html();
			//渲染模板
			var data = {'apply_id':apply_id};
			laytpl(getTpl).render(data, function (html) {
				layer.open({
					type: 1,
					shadeClose: true,
					shade: 0.3,
					fixed: false,
					scrollbar: false,
					title: "审核",
					area: '800px',
					btn: ['提交'],
					yes: function (index, layero) {
						$("#button_delivery_order").click();
					},
					content: html,
					cancel: function (index, layero) {
						//右上角关闭回调
						layer.close(index);
						//return false 开启该代码可禁止点击该按钮关闭
					},
					success: function (layero, index) {
						form.render();

						form.on('submit(button_delivery_order)', function (data) {
							if (data.field.commission_rate==''||data.field.commission_rate==0){
								layer.msg('请输入抽佣比例', {time: 2000, icon: 5});
								return;
							}

							if (data.field.username==''){
								layer.msg('请输入商家登录用户名', {time: 2000, icon: 5});
								return;
							}

							if (data.field.password==''){
								layer.msg('请输入商家登录密码', {time: 2000, icon: 5});
								return;
							}

							if (submitting) {
								return false;
							}
							submitting = true;
							$.ajax({
								type: "post",
								url: '{:addon_url("admin/shopapply/applyAudit")}',
								async: true,
								dataType: 'json',
								data: data.field,
								success: function (res) {
									if (res.code == 0) {
										layer.msg("审核成功");
										location.reload();
									} else {
										layer.msg(res.message);
										submitting = false;
									}
								}
							})
						});

					}

				});
			})

		})
	}


</script>